package dshop.service;

import java.util.List;
import java.util.Map;

import appbase.third.chuanglan.SnsKit;
import appbase.utils.ListUtil;
import dshop.model.member.MemberGeneralInfo;

public class SnsPushService {
	
	
	public static void pushProcurement(Map<String, List<Integer>> tagToUserListMap)
	{
		if (tagToUserListMap == null || tagToUserListMap.isEmpty())
		{
			return;
		}
		
		for (String tag : tagToUserListMap.keySet()) 
		{
			List<Integer> userIdList = tagToUserListMap.get(tag);
			pushProcurement(userIdList, tag);
		}
	}
	
	private static void pushProcurement(List<Integer> userIdList, String tag)
	{
		List<String> phoneList = MemberGeneralInfo.findPhoneList(userIdList);
		if (phoneList == null || phoneList.isEmpty())
		{
			return;
		}
		
		if (tag.length() > 6)
		{
			tag = tag.substring(0, 6);
		}
		
		String msgText = "你有一条关于“" + tag + "”的及时通推送信息--帝全";
		String phones = ListUtil.joinToStr(phoneList, ",");
		SnsKit.sendMessage(phones, msgText);
	}

	
}
